package com.xja.shoppingmall.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author CHENCHEN
 * @title
 * @createTime 2021-12-1021:10
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CommonResponseVO implements Serializable {

    //返回状态码 0 成功； -1 失败
    private Integer code;

    //返回提示消息
    private String msg;

    //返回数据
    private Object data;

    public CommonResponseVO(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    //成功——无返回数据
    public static CommonResponseVO SUCCESS = new CommonResponseVO(0, "success");

    /**
     * 成功——有返回数据
     * @param msg
     * @param data
     * @return
     */
    public static CommonResponseVO SUCCESS(String msg, Object data){
        return new CommonResponseVO(0, msg, data);
    }

    //失败——无返回数据
    public static CommonResponseVO FAIL = new CommonResponseVO(-1, "fail");

    /**
     * 失败——有返回数据
     * @param msg
     * @param data
     * @return
     */
    public static CommonResponseVO FAIL(String msg, Object data){
        return new CommonResponseVO(-1, msg, data);
    }
}
